home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / DJGPP / BNU22SR1.ZIP / src / binutils.2 / bfd / libcoff.h < prev    next >
C/C++ Source or Header  |  1993-05-30  |  12KB  |  340 lines

  1. /* BFD COFF object file private structure.
  2.    Copyright (C) 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
  3.    Written by Cygnus Support.
  4.  
  5. This file is part of BFD, the Binary File Descriptor library.
  6.  
  7. This program is free software; you can redistribute it and/or modify
  8. it under the terms of the GNU General Public License as published by
  9. the Free Software Foundation; either version 2 of the License, or
  10. (at your option) any later version.
  11.  
  12. This program is distributed in the hope that it will be useful,
  13. but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. GNU General Public License for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with this program; if not, write to the Free Software
  19. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  20.  
  21.  
  22. /* Object file tdata; access macros */
  23.  
  24. #define coff_data(bfd)        ((bfd)->tdata.coff_obj_data)
  25. #define exec_hdr(bfd)        (coff_data(bfd)->hdr)
  26. #define obj_symbols(bfd)    (coff_data(bfd)->symbols)
  27. #define    obj_sym_filepos(bfd)    (coff_data(bfd)->sym_filepos)
  28.  
  29. #define obj_relocbase(bfd)    (coff_data(bfd)->relocbase)
  30. #define obj_raw_syments(bfd)    (coff_data(bfd)->raw_syments)
  31. #define obj_raw_syment_count(bfd)    (coff_data(bfd)->raw_syment_count)
  32. #define obj_convert(bfd)    (coff_data(bfd)->conversion_table)
  33. #define obj_conv_table_size(bfd) (coff_data(bfd)->conv_table_size)
  34. #if CFILE_STUFF
  35. #define obj_symbol_slew(bfd)    (coff_data(bfd)->symbol_index_slew)
  36. #else
  37. #define obj_symbol_slew(bfd) 0
  38. #endif
  39.  
  40.  
  41. /* `Tdata' information kept for COFF files.  */
  42.  
  43. typedef struct coff_tdata
  44. {
  45.   struct   coff_symbol_struct *symbols;    /* symtab for input bfd */
  46.   unsigned int *conversion_table;
  47.   int conv_table_size;
  48.   file_ptr sym_filepos;
  49.  
  50.   long symbol_index_slew;    /* used during read to mark whether a
  51.                    C_FILE symbol as been added. */
  52.  
  53.   struct coff_ptr_struct *raw_syments;
  54.   struct lineno *raw_linenos;
  55.   unsigned int raw_syment_count;
  56.   unsigned short flags;
  57.  
  58.   /* These are only valid once writing has begun */
  59.   long int relocbase;
  60.  
  61.   /* These members communicate important constants about the symbol table
  62.      to GDB's symbol-reading code.  These `constants' unfortunately vary
  63.      from coff implementation to implementation...  */
  64.   unsigned local_n_btmask;
  65.   unsigned local_n_btshft;
  66.   unsigned local_n_tmask;
  67.   unsigned local_n_tshift;
  68.   unsigned local_symesz;
  69.   unsigned local_auxesz;
  70.   unsigned local_linesz;
  71. } coff_data_type;
  72.  
  73. /* We take the address of the first element of a asymbol to ensure that the
  74.  * macro is only ever applied to an asymbol.  */
  75. #define coffsymbol(asymbol) ((coff_symbol_type *)(&((asymbol)->the_bfd)))
  76.  
  77. /* Functions in coffgen.c.  */
  78. extern bfd_target *coff_object_p PARAMS ((bfd *));
  79. extern struct sec *coff_section_from_bfd_index PARAMS ((bfd *, int));
  80. extern unsigned int coff_get_symtab_upper_bound PARAMS ((bfd *));
  81. extern unsigned int coff_get_symtab PARAMS ((bfd *, asymbol **));
  82. extern int coff_count_linenumbers PARAMS ((bfd *));
  83. extern struct coff_symbol_struct *coff_symbol_from PARAMS ((bfd *, asymbol *));
  84. extern void coff_renumber_symbols PARAMS ((bfd *));
  85. extern void coff_mangle_symbols PARAMS ((bfd *));
  86. extern void coff_write_symbols PARAMS ((bfd *));
  87. extern void coff_write_linenumbers PARAMS ((bfd *));
  88. extern alent *coff_get_lineno PARAMS ((bfd *, asymbol *));
  89. extern asymbol *coff_section_symbol PARAMS ((bfd *, char *));
  90. extern struct coff_ptr_struct *coff_get_normalized_symtab PARAMS ((bfd *));
  91. extern unsigned int coff_get_reloc_upper_bound PARAMS ((bfd *, sec_ptr));
  92. extern asymbol *coff_make_empty_symbol PARAMS ((bfd *));
  93. extern void coff_print_symbol PARAMS ((bfd *, PTR filep, asymbol *,
  94.                        bfd_print_symbol_type how));
  95. extern asymbol *coff_bfd_make_debug_symbol PARAMS ((bfd *, PTR,
  96.                             unsigned long));
  97. extern boolean coff_find_nearest_line PARAMS ((bfd *,
  98.                            asection *,
  99.                            asymbol **,
  100.                            bfd_vma offset,
  101.                            CONST char **filename_ptr,
  102.                            CONST char **functionname_ptr,
  103.                            unsigned int *line_ptr));
  104. extern int coff_sizeof_headers PARAMS ((bfd *, boolean reloc));
  105. extern boolean bfd_coff_reloc16_relax_section PARAMS ((bfd *,
  106.                                asection *,
  107.                                asymbol **));
  108. extern bfd_byte *bfd_coff_reloc16_get_relocated_section_contents
  109.   PARAMS ((bfd *, struct bfd_seclet *, bfd_byte *, boolean relocateable));
  110. extern bfd_vma bfd_coff_reloc16_get_value PARAMS ((arelent *,
  111.                            struct bfd_seclet *));
  112.  
  113. /* And more taken from the source .. */
  114.  
  115. typedef struct coff_ptr_struct 
  116. {
  117.  
  118.         /* Remembers the offset from the first symbol in the file for
  119.           this symbol. Generated by coff_renumber_symbols. */
  120. unsigned int offset;
  121.  
  122.         /* Should the tag field of this symbol be renumbered.
  123.           Created by coff_pointerize_aux. */
  124. char fix_tag;
  125.  
  126.         /* Should the endidx field of this symbol be renumbered.
  127.           Created by coff_pointerize_aux. */
  128. char fix_end;
  129.  
  130.         /* The container for the symbol structure as read and translated
  131.            from the file. */
  132.  
  133. union {
  134.    union internal_auxent auxent;
  135.    struct internal_syment syment;
  136.  } u;
  137. } combined_entry_type;
  138.  
  139.  
  140.  /* Each canonical asymbol really looks like this: */
  141.  
  142. typedef struct coff_symbol_struct
  143. {
  144.     /* The actual symbol which the rest of BFD works with */
  145. asymbol symbol;
  146.  
  147.     /* A pointer to the hidden information for this symbol */
  148. combined_entry_type *native;
  149.  
  150.     /* A pointer to the linenumber information for this symbol */
  151. struct lineno_cache_entry *lineno;
  152.  
  153.     /* Have the line numbers been relocated yet ? */
  154. boolean done_lineno;
  155. } coff_symbol_type;
  156. typedef struct 
  157. {
  158.   void (*_bfd_coff_swap_aux_in) PARAMS ((
  159.        bfd            *abfd ,
  160.        PTR             ext,
  161.        int             type,
  162.        int             class ,
  163.        PTR             in));
  164.  
  165.   void (*_bfd_coff_swap_sym_in) PARAMS ((
  166.        bfd            *abfd ,
  167.        PTR             ext,
  168.        PTR             in));
  169.  
  170.   void (*_bfd_coff_swap_lineno_in) PARAMS ((
  171.        bfd            *abfd,
  172.        PTR            ext,
  173.        PTR             in));
  174.  
  175.  unsigned int (*_bfd_coff_swap_aux_out) PARAMS ((
  176.        bfd       *abfd,
  177.        PTR    in,
  178.        int        type,
  179.        int        class,
  180.        PTR        ext));
  181.  
  182.  unsigned int (*_bfd_coff_swap_sym_out) PARAMS ((
  183.       bfd      *abfd,
  184.       PTR    in,
  185.       PTR    ext));
  186.  
  187.  unsigned int (*_bfd_coff_swap_lineno_out) PARAMS ((
  188.           bfd       *abfd,
  189.           PTR    in,
  190.     PTR    ext));
  191.  
  192.  unsigned int (*_bfd_coff_swap_reloc_out) PARAMS ((
  193.           bfd     *abfd,
  194.          PTR    src,
  195.     PTR    dst));
  196.  
  197.  unsigned int (*_bfd_coff_swap_filehdr_out) PARAMS ((
  198.           bfd      *abfd,
  199.     PTR     in,
  200.     PTR     out));
  201.  
  202.  unsigned int (*_bfd_coff_swap_aouthdr_out) PARAMS ((
  203.           bfd     *abfd,
  204.     PTR     in,
  205.     PTR    out));
  206.  
  207.  unsigned int (*_bfd_coff_swap_scnhdr_out) PARAMS ((
  208.           bfd      *abfd,
  209.           PTR    in,
  210.     PTR    out));
  211.  
  212.  unsigned int _bfd_filhsz;
  213.  unsigned int _bfd_aoutsz;
  214.  unsigned int _bfd_scnhsz;
  215.  unsigned int _bfd_symesz;
  216.  unsigned int _bfd_auxesz;
  217.  unsigned int _bfd_linesz;
  218.  boolean _bfd_coff_long_filenames;
  219.  void (*_bfd_coff_swap_filehdr_in) PARAMS ((
  220.        bfd     *abfd,
  221.        PTR     ext,
  222.        PTR     in));
  223.  void (*_bfd_coff_swap_aouthdr_in) PARAMS ((
  224.        bfd     *abfd,
  225.        PTR     ext,
  226.        PTR     in));
  227.  void (*_bfd_coff_swap_scnhdr_in) PARAMS ((
  228.        bfd     *abfd,
  229.        PTR     ext,
  230.        PTR     in));
  231.  boolean (*_bfd_coff_bad_format_hook) PARAMS ((
  232.        bfd     *abfd,
  233.        PTR     internal_filehdr));
  234.  boolean (*_bfd_coff_set_arch_mach_hook) PARAMS ((
  235.        bfd     *abfd,
  236.        PTR     internal_filehdr));
  237.  PTR (*_bfd_coff_mkobject_hook) PARAMS ((
  238.        bfd     *abfd,
  239.        PTR     internal_filehdr,
  240.        PTR     internal_aouthdr));
  241.  flagword (*_bfd_styp_to_sec_flags_hook) PARAMS ((
  242.        bfd     *abfd,
  243.        PTR     internal_scnhdr));
  244.  asection *(*_bfd_make_section_hook) PARAMS ((
  245.        bfd     *abfd,
  246.        char    *name));
  247.  void (*_bfd_set_alignment_hook) PARAMS ((
  248.        bfd     *abfd,
  249.        asection *sec,
  250.        PTR     internal_scnhdr));
  251.  boolean (*_bfd_coff_slurp_symbol_table) PARAMS ((
  252.        bfd     *abfd));
  253.  boolean (*_bfd_coff_symname_in_debug) PARAMS ((
  254.        bfd     *abfd,
  255.        struct internal_syment *sym));
  256.  void (*_bfd_coff_reloc16_extra_cases) PARAMS ((
  257.        bfd     *abfd,
  258.        struct bfd_seclet *seclet,
  259.        arelent *reloc,
  260.        bfd_byte *data,
  261.        unsigned int *src_ptr,
  262.        unsigned int *dst_ptr));
  263. } bfd_coff_backend_data;
  264.  
  265. #define coff_backend_info(abfd) ((bfd_coff_backend_data *) (abfd)->xvec->backend_data)
  266.  
  267. #define bfd_coff_swap_aux_in(a,e,t,c,i) \
  268.         ((coff_backend_info (a)->_bfd_coff_swap_aux_in) (a,e,t,c,i))
  269.  
  270. #define bfd_coff_swap_sym_in(a,e,i) \
  271.         ((coff_backend_info (a)->_bfd_coff_swap_sym_in) (a,e,i))
  272.  
  273. #define bfd_coff_swap_lineno_in(a,e,i) \
  274.         ((coff_backend_info ( a)->_bfd_coff_swap_lineno_in) (a,e,i))
  275.  
  276. #define bfd_coff_swap_reloc_out(abfd, i, o) \
  277.         ((coff_backend_info (abfd)->_bfd_coff_swap_reloc_out) (abfd, i, o))
  278.  
  279. #define bfd_coff_swap_lineno_out(abfd, i, o) \
  280.         ((coff_backend_info (abfd)->_bfd_coff_swap_lineno_out) (abfd, i, o))
  281.  
  282. #define bfd_coff_swap_aux_out(abfd, i, t,c,o) \
  283.         ((coff_backend_info (abfd)->_bfd_coff_swap_aux_out) (abfd, i,t,c, o))
  284.  
  285. #define bfd_coff_swap_sym_out(abfd, i,o) \
  286.         ((coff_backend_info (abfd)->_bfd_coff_swap_sym_out) (abfd, i, o))
  287.  
  288. #define bfd_coff_swap_scnhdr_out(abfd, i,o) \
  289.         ((coff_backend_info (abfd)->_bfd_coff_swap_scnhdr_out) (abfd, i, o))
  290.  
  291. #define bfd_coff_swap_filehdr_out(abfd, i,o) \
  292.         ((coff_backend_info (abfd)->_bfd_coff_swap_filehdr_out) (abfd, i, o))
  293.  
  294. #define bfd_coff_swap_aouthdr_out(abfd, i,o) \
  295.         ((coff_backend_info (abfd)->_bfd_coff_swap_aouthdr_out) (abfd, i, o))
  296.  
  297. #define bfd_coff_filhsz(abfd) (coff_backend_info (abfd)->_bfd_filhsz)
  298. #define bfd_coff_aoutsz(abfd) (coff_backend_info (abfd)->_bfd_aoutsz)
  299. #define bfd_coff_scnhsz(abfd) (coff_backend_info (abfd)->_bfd_scnhsz)
  300. #define bfd_coff_symesz(abfd) (coff_backend_info (abfd)->_bfd_symesz)
  301. #define bfd_coff_auxesz(abfd) (coff_backend_info (abfd)->_bfd_auxesz)
  302. #define bfd_coff_linesz(abfd) (coff_backend_info (abfd)->_bfd_linesz)
  303. #define bfd_coff_long_filenames(abfd) (coff_backend_info (abfd)->_bfd_coff_long_filenames)
  304. #define bfd_coff_swap_filehdr_in(abfd, i,o) \
  305.         ((coff_backend_info (abfd)->_bfd_coff_swap_filehdr_in) (abfd, i, o))
  306.  
  307. #define bfd_coff_swap_aouthdr_in(abfd, i,o) \
  308.         ((coff_backend_info (abfd)->_bfd_coff_swap_aouthdr_in) (abfd, i, o))
  309.  
  310. #define bfd_coff_swap_scnhdr_in(abfd, i,o) \
  311.         ((coff_backend_info (abfd)->_bfd_coff_swap_scnhdr_in) (abfd, i, o))
  312.  
  313. #define bfd_coff_bad_format_hook(abfd, filehdr) \
  314.         ((coff_backend_info (abfd)->_bfd_coff_bad_format_hook) (abfd, filehdr))
  315.  
  316. #define bfd_coff_set_arch_mach_hook(abfd, filehdr)\
  317.         ((coff_backend_info (abfd)->_bfd_coff_set_arch_mach_hook) (abfd, filehdr))
  318. #define bfd_coff_mkobject_hook(abfd, filehdr, aouthdr)\
  319.         ((coff_backend_info (abfd)->_bfd_coff_mkobject_hook) (abfd, filehdr, aouthdr))
  320.  
  321. #define bfd_coff_styp_to_sec_flags_hook(abfd, scnhdr)\
  322.         ((coff_backend_info (abfd)->_bfd_styp_to_sec_flags_hook) (abfd, scnhdr))
  323.  
  324. #define bfd_coff_make_section_hook(abfd, name)\
  325.         ((coff_backend_info (abfd)->_bfd_make_section_hook) (abfd, name))
  326.  
  327. #define bfd_coff_set_alignment_hook(abfd, sec, scnhdr)\
  328.         ((coff_backend_info (abfd)->_bfd_set_alignment_hook) (abfd, sec, scnhdr))
  329.  
  330. #define bfd_coff_slurp_symbol_table(abfd)\
  331.         ((coff_backend_info (abfd)->_bfd_coff_slurp_symbol_table) (abfd))
  332.  
  333. #define bfd_coff_symname_in_debug(abfd, sym)\
  334.         ((coff_backend_info (abfd)->_bfd_coff_symname_in_debug) (abfd, sym))
  335.  
  336. #define bfd_coff_reloc16_extra_cases(abfd, seclet, reloc, data, src_ptr, dst_ptr)\
  337.         ((coff_backend_info (abfd)->_bfd_coff_reloc16_extra_cases)\
  338.          (abfd, seclet, reloc, data, src_ptr, dst_ptr))
  339.  
  340.